// 引入二次封装的 axios
import request from "@/utils/request";
// 引入接口数据的 ts 类型
import { HospitalDetailData, DepartmentData, HospitalWorkData, DoctorData, VisitorData, ScheduleData, SubmitOrderData } from "./type";

// 枚举请求地址
enum API {
    // 医院详细信息地址
    HOSPITALDETAIL_URL = "/hosp/hospital/",
    // 医院科室地址
    HOSPITALDEPARTMENT_URL = "/hosp/hospital/department/",
    // 医院科室预约挂号地址
    HOSPITALWORK_URL = "/hosp/hospital/auth/getBookingScheduleRule/",
    // 医生排班接口地址
    DOCTORWORK_URL = "/hosp/hospital/auth/findScheduleList/",
    // 某一账号下就诊人信息
    GETUSER_URL = "/user/patient/auth/findAll",
    // 根据医生 id 获取排班 
    SCHEDULE_URL = "/hosp/hospital/getSchedule/",
    // 创建订单接口
    SUBMITORDER_URL = "/order/orderInfo/auth/submitOrder/"
}

// 获取医院详情的接口
export const reqHospitalDetail = (hoscode: string) => request.get<any, HospitalDetailData>(API.HOSPITALDETAIL_URL + hoscode);

// 获取医院科室的接口
export const reqHospitalDepartment = (hoscode: string) => request.get<any, DepartmentData>(API.HOSPITALDEPARTMENT_URL + hoscode);

// 获取某医院某科室预约挂号数据
export const reqHospitalWork = (page: number, limit: number, hoscode: string, depcode: string) => request.get<any, HospitalWorkData>(API.HOSPITALWORK_URL + `${page}/${limit}/${hoscode}/${depcode}`);

// 获取医生排班的接口
export const reqDoctorWork = (hoscode: string, depcode: string, workDate: string) => request.get<any, DoctorData>(API.DOCTORWORK_URL + `${hoscode}/${depcode}/${workDate}`);

// 获取某一账号下就诊人信息
export const reqGetUser = () => request.get<any, VisitorData>(API.GETUSER_URL);

// 根据 id 获取排班信息
export const reqSchedule = (scheduleId: string) => request.get<any, ScheduleData>(API.SCHEDULE_URL + scheduleId);

// 创建订单
export const reqSubmitOrder = (hoscode: string, scheduleId: string, patientId: number) => request.post<any, SubmitOrderData>(API.SUBMITORDER_URL + `${hoscode}/${scheduleId}/${patientId}`)
